package com.pubinfo.passbook.api.controller.other;

import com.pubinfo.passbook.common.model.vo.base.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
@RequestMapping("probe")
@Api(tags = "探针专用")
@Slf4j
public class ProbeController {
  
  protected static final Logger logger = LoggerFactory.getLogger(ProbeController.class);
  
  @GetMapping("get")
  @ApiOperation("探针")
  public JsonResult<String> probe() {
    return JsonResult.success("我还活着");
  }
  
  private String tag() {
    return (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date());
  }
  
  private Long get(HttpServletRequest request, String name) {
    
    return Long.valueOf(request.getParameter(name));
  }
//
//  @GetMapping("/tracegson")
//  @ApiOperation("gson调试")
//  public String tracegson(HttpServletRequest request, Model model) {
//
//    Long name = get(request, "name");
//    Long age = get(request, "age");
//
//    PageParamBase student = new PageParamBase();
//
//    student.setSize(age);
//
//    Gson gson = new Gson();
//
//    String parseStr = gson.toJson(student, PageParamBase.class);
//    logger.info("pinpoint_bizlog_name 1. [" + name + "], age [" + age + "]");
//
//    logger.info("gson str [{}]", parseStr);
//
//    return String.format("gson str : %s [%s]", parseStr, tag());
//  }
  
}
